package com.shd.edanpei.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseActivity;
import com.shd.edanpei.common.Constant;
import com.shd.edanpei.presenter.contract.WithdrawalContract;
import com.shd.edanpei.presenter.WithdrawalPresenter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by mc on 2018/4/4.
 * 提现至银行卡
 */

public class WithdrawalToBank extends BaseActivity<WithdrawalPresenter>
        implements WithdrawalContract.WithdrawalIView {

    @BindView(R.id.headline)
    TextView headline;
    @BindView(R.id.et_bank_username)
    EditText etUserName;
    @BindView(R.id.et_bank_cardnumber)
    EditText etCardNumber;
    @BindView(R.id.et_bank_name)
    EditText etBankName;
    @BindView(R.id.et_bank_openbank)
    EditText etOpenBank;

    private String mAmount;

    @Override
    protected int setLayout() {
        return R.layout.withdraw_bank_edit;
    }

    @Override
    protected WithdrawalPresenter bindPresenter() {
        return new WithdrawalPresenter(this);
    }

    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {
        headline.setText("提现至银行卡");
        Bundle extras = getIntent().getExtras();
        mAmount = extras.getString(Constant.AMOUNT);
    }

    @Override
    protected void initListener() {

    }

    @OnClick({R.id.iv_headline_back, R.id.tv_button})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_headline_back:
                finish();
                break;
            case R.id.tv_button:
                if (etData(etUserName, etCardNumber, etBankName, etOpenBank)) {
                    mPresenter.submit(Constant.withdraw.bank, mAmount, etUserName.getText().toString(),
                            etCardNumber.getText().toString(), etBankName.getText().toString(),
                            etOpenBank.getText().toString());
                }
                break;
        }
    }
}
